<template>
  <el-form :model="tasks" label-width="auto" style="max-width: 600px">
    <el-form-item label="任务名称">
      <el-input v-model="tasks.project" placeholder="请输入任务名称"/>
    </el-form-item>

    <el-form-item label="任务负责人">
      <el-input v-model="tasks.name" placeholder="请输入任务负责人"/>
    </el-form-item>

    <el-form-item label="完成时间">
      <el-col :span="11">
        <el-date-picker
          v-model="tasks.deadline"
          type="date"
          placeholder="Pick a date"
          style="width: 100%"
        />
      </el-col>
      <el-col :span="2" class="text-center">
        <span class="text-gray-500">-</span>
      </el-col>

    </el-form-item>

    <el-form-item label="任务等级">
      <el-select v-model="tasks.level" placeholder="请选择任务等级">
        <el-option label="紧急" value="紧急" />
        <el-option label="中等" value="中等" />
        <el-option label="普通" value="普通" />
      </el-select>
    </el-form-item>


    <el-form-item label="任务描述">
      <el-input v-model="tasks.description" type="textarea" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">完成</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import http from '../../http';
const tasks = ref({
  name: '',
  deadline: new Date().toISOString().split('T')[0],
  level: '',
  project: '',
  description: '',
})

const onSubmit = () => {
  http.post("task/", tasks.value).then(res => {
    if (res.data.code === 200) {
      alert("任务创建成功")
      console.log(res.data)
    }
  })
  console.log('submit!')
}


</script>

<style scoped>

</style>